(define (filtered-accumlate filter combiner null-value term a next b)
    (if (> a b)
        null-value
        (if (filter a)
            (combiner (term a)
                (filtered-accumlate filter combiner null-value term (next a) next b)
            )
            (filtered-accumlate filter combiner null-value term (next a) next b)
        )    
    )
)
; ex1.23
(define (smallest-divisor n)
        (find-divisor n 2)
)
(define (find-divisor n test-divisor)
        (cond ((> (* test-divisor test-divisor) n) n)
            ((dividers? test-divisor n) test-divisor)
            (else (find-divisor n (next test-divisor )))
        )
)
(define (dividers? a b)
        (= (remainder b a) 0)
)

(define (next test-divisor)
    (if (= 2 test-divisor)
        3
        (+ test-divisor 2)
    )
)

(define (prime? n)
    (= n (smallest-divisor n))
)

(define (add-prime a b)
    (define (term x) x)
    (define (next n) (+ n 1))
    (filtered-accumlate prime? + 0 term a next b)    
)
(display (add-prime 2 100))
(newline)

(define (my-multi n)
    (define (filter? x)
        (= (gcd x n) 1)
    )
    (define (term x) x)
    (define (next x) (+ x 1))
    (filtered-accumlate filter? * 1 term 1 next n)
)
(display (my-multi 7))
(exit)
